/*
 * ========================================================================
 *
 *       Filename:  studyboard.h
 *
 *    Description:  This defines the studyboard panel for the flashboard.
 *
 *        Version:  1.0
 *        Created:  05/11/2010 11:28:03 PM
 *       Revision:  none
 *       Compiler:  g++
 *
 *         Author:  Alex Avance (aa), aravance@gmail.com
 *        Company:  independent
 *
 * ========================================================================
 *
 * Copyright (C) 2010 Alex Avance
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
 * 1307, USA.
 *
 * ========================================================================
 */
#ifndef _STUDYBOARD_H_
#define _STUDYBOARD_H_

#include "wx/frame.h"
#include "wx/panel.h"
#include "wx/button.h"
#include "wx/listbox.h"
#include "cstmtxtctrl.h"
#include "constants.h"
#include "deck.h"

class StudyBoardPanel: public wxPanel
{
public:
  // ====================  LIFECYCLE      ===============================
  StudyBoardPanel ( wxFrame *parent, StudyDeck &deck );
  virtual ~StudyBoardPanel ();

  // ====================  ACCESSORS      ===============================
  bool IsModified () const;

  bool ConfirmSwitch ( bool force= false );
  int ConfirmSwitchCard ();

  // ====================  MUTATORS       ===============================
  void Unmodified ();
  void Reset ();
  void Update ();
  void UpdateButtons ();

  void BuildList ();

  void UpdateCardEntry ( size_t pos );
  void SaveCard ( size_t pos= -1 );
  void DelCard ( size_t pos= -1 );
  void SelectCard ( size_t pos );

  virtual bool Show ( bool show= true );
  
  // ====================  EVENT HANDLERS ===============================
  void OnSaveCard ( wxCommandEvent &event );
  void OnDelCard ( wxCommandEvent &event );
  void OnHideList ( wxCommandEvent &event );

  void OnSelect ( wxCommandEvent &event );
  void OnDoubleClick ( wxCommandEvent &event );

  void OnShuffle ( wxCommandEvent &event );
  void OnSort ( wxCommandEvent &event );
  void OnNext ( wxCommandEvent &event );
  void OnPrev ( wxCommandEvent &event );

  // ====================  DATA MEMBERS   ===============================
protected:
  wxFrame *m_Parent;

  wxButton *m_ButtonShuf;
  wxButton *m_ButtonSort;
  wxButton *m_ButtonNext;
  wxButton *m_ButtonPrev;

  wxListBox *m_ListBox;

  CustomTextCtrl *m_TextFront;
  CustomTextCtrl *m_TextBack;

  StudyDeck &m_Deck;

  bool m_Modified;

  size_t m_CurrentSelection;

private:
  DECLARE_EVENT_TABLE()
}; // ----- end of class StudyBoardPanel -----

#endif // _STUDYBOARD_H_

